﻿using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using ControleRepresentante.Logic.Models;
using WebSite.ViewModels.EditViewModels.EditGridViewModels;
using WebSite.ViewModels.Fields;

namespace WebSite.ViewModels.EditViewModels
{
    public class RepresentanteEditViewModel : EditViewModel
    {
        public RepresentanteEditViewModel()
            : base("Representante")
        {
        }

        protected override IEnumerable<IField> GetGeralFields()
        {
            Representante representante = (Representante) Model;

            List<IField> result = new List<IField>
            {
                new TextBoxField("Nome", "nome", representante.Nome, true),
                new CheckBoxField("Ativo", "ativo", representante.Ativo),
                new CheckBoxField("Usa Jolitex", "useJolitex", representante.UseJolitex),
                new CheckBoxField("Usa Trivium", "useTrivium", representante.UseTrivium),
            };
            result.AddRange(base.GetGeralFields());
            return result;
        }

        protected override IEnumerable<TabItem> GetTabs(HtmlHelper htmlHelper)
        {
            List<TabItem> result = base.GetTabs(htmlHelper).ToList();

            Representante representante = (Representante)Model;

            result.Add(new TabItem("Usuários",
                "~/Content/users.png",
                new UsuarioEditGridViewModel(htmlHelper, ControllerName, representante.Users, "UserId")));

            return result;
        }
    }
}